#include "Tile.h"

#include "SGD Wrappers\CSGD_TextureManager.h"

#include "Game.h"

Tile::Tile(void)
{
	type = OBJECT_TILE;
	solid = false;
	onScreen = false;
}
Tile::~Tile(void)
{
}

void Tile::Render()
{
	if(Entity::GetTextureID() != -1 && Entity::GetRect().right <= Game::GetInstance()->GetScreenWidth() && Entity::GetRect().left >= 0
		&& Entity::GetRect().top >= 0 && Entity::GetRect().bottom <= Game::GetInstance()->GetScreenHeight())
	{
		onScreen = true;
		CSGD_TextureManager::GetInstance()->Draw(Entity::GetTextureID(), int(Entity::GetX()), int(Entity::GetY()));
	}
	else
		onScreen = false;
}

bool Tile::CheckCollision(IEntity* base) 
{
	// Get intersect rect
	RECT rect = {};

	// Check if colliding and the object is solid
	if(IntersectRect(&rect, &base->GetRect(), &GetRect()) && solid == true)
		return true;

	// Not true return false
	return false;
}
